export default {
  state:{
    name: 'zhangsan'
  },
  getters:{
    fullname(state) {
      return state.name + '1111' 
    },
    fullname2(state, getters) {
      return getters.fullname + '2222'
    },
    // 访问总模块 rootState
    fullname3(state, getters, rootState) {
      return getters.fullname2 + rootState.counter
    }
  },
  mutations:{
    upName(state, payload) {
      state.name = payload.name || 'lisi'
    }
  },
  actions:{
    aUpName(context, payload) {
      // 这里的 context.commit() 只提交自己的 mutations
      setTimeout(() => {
        context.commit('upName', payload)
      }, 1000);
    }
  }
}